CREATE TABLE [agency].[Company]
(
[CompanyId] [int] NOT NULL IDENTITY(1, 1),
[CompanyTypeId] [int] NOT NULL,
[ParentCompanyId] [int] NULL,
[Code] [int] NOT NULL,
[Name] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[EstablishedDate] [datetime] NOT NULL,
[Active] [bit] NOT NULL,
[Deleted] [bit] NOT NULL,
[CreatedBy] [int] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[ModifiedBy] [int] NULL,
[ModifiedOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [agency].[Company] ADD CONSTRAINT [PK_Company] PRIMARY KEY CLUSTERED  ([CompanyId]) ON [PRIMARY]
GO
ALTER TABLE [agency].[Company] ADD CONSTRAINT [FK_Company_CompanyType] FOREIGN KEY ([CompanyTypeId]) REFERENCES [agency].[CompanyType] ([CompanyTypeId])
GO
ALTER TABLE [agency].[Company] ADD CONSTRAINT [FK_Company_Company] FOREIGN KEY ([ParentCompanyId]) REFERENCES [agency].[Company] ([CompanyId])
GO
